package com.weng.platform.guest.api;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.weng.framework.core.model.ResponseData;
import com.weng.framework.web.base.BaseController;
import com.weng.platform.guest.entity.TimeRecord;
import com.weng.platform.guest.model.vo.TimeRecordVo;
import com.weng.platform.guest.service.ITimeRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 生活记录 API实现
 *
 * @author weng
 * @date 2021-06-03 23:37:38
 *
 */  
@Slf4j
@RestController
@RequestMapping("/guest/time-records")
@Api(value = "生活记录api", tags = {"生活记录操作接口"})
public class TimeRecordApi extends BaseController {
    @Autowired
    private ITimeRecordService timeRecordService;




    /**
     * 条件 分页查询生活记录
     */
    @ApiOperation(value = "分页获取生活记录", notes = "")
    @GetMapping(value = "")
    public ResponseData list(Integer pageNo,Integer pageSize){
		IPage<TimeRecord> iPage = timeRecordService.list(pageNo, pageSize);
        return success(iPage);
    }


    /**
	 * 新增生活记录
	 */
	@ApiOperation(value = "新增生活记录", notes = "")
	@PostMapping(value = "")
	public ResponseData add(@Valid @RequestBody TimeRecordVo timeRecordReq){
		TimeRecord timeRecord = Convert.convert(TimeRecord.class, timeRecordReq);
		timeRecordService.add(timeRecord);
		return success();
	}


}
